import { instance } from "@/service/request/request";
import MockAdapter from "axios-mock-adapter";

import _ from "lodash";

export const mock = new MockAdapter(instance, {
    delayResponse: _.random(500, 1000),
});

export type MockAdapterInstance = InstanceType<typeof MockAdapter>;

// 模块化mock配置
interface MockModule {
    default: (mock: MockAdapterInstance) => void;
}

const mockModules = import.meta.glob<MockModule>("./modules/*.ts", {
    eager: true,
});

// 初始化所有mock
Object.values(mockModules).forEach((module) => {
    module.default(mock);
});

export default mockModules;
